package com.qingchi.web.controller.social;

import com.socialuni.social.api.TalkApi;
import com.socialuni.social.model.QO.talk.TalkAddVO;
import com.socialuni.social.model.QO.talk.TalkDeleteVO;
import com.socialuni.social.model.QO.talk.UserTalkQueryVO;
import com.socialuni.social.model.RO.talk.TalkDetailVO;
import com.socialuni.social.model.RO.talk.TalkQueryVO;
import com.socialuni.social.model.common.ResultRO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.List;

@RestController
public class TalkController implements TalkApi {
    @Resource
    TalkApi talkApi;

    @Override
    public ResultRO<List<TalkDetailVO>> queryTalks() {
        return talkApi.queryTalks();
    }

    //查询官方置顶的talks
    //没有商户号的情况下，appGender也可以人工设置不为空
    @Override
    public ResultRO<List<TalkDetailVO>> queryTalks(@RequestBody TalkQueryVO queryVO) {
        return talkApi.queryTalks(queryVO);
    }

    @Override
    public ResultRO<TalkDetailVO> queryTalkDetail(@Valid @NotNull String talkId) {
        return talkApi.queryTalkDetail(talkId);
    }

    @Override
    public ResultRO<List<TalkDetailVO>> queryUserTalks(@RequestBody @Valid @NotNull(message = "参数异常") UserTalkQueryVO queryVO) {
        return talkApi.queryUserTalks(queryVO);
    }

    @Override
    public ResultRO<Object> addTalk(@RequestBody @Valid @NotNull TalkAddVO talkVO) throws IOException {
        return talkApi.addTalk(talkVO);
    }

    @Override
    public ResultRO<Object> deleteTalk(@RequestBody @Valid TalkDeleteVO talkVO) {
        return talkApi.deleteTalk(talkVO);
    }

}